﻿@{
    Layout = "";
}
<style>
    .ngdialog.ngdialog-theme-plain .ngdialog-content {
        width: 45% !important;
    }
</style>
<div ng-controller="MemberDetailController">
    <div class="container-fluid" ng-show="!selectProduct" id="AgentInfoUpdateMainViewPanel">
        <div class="row">
            <div class="col-md-12">
                <form name="formValidate" ng-submit="submitForm()" novalidate="" class="form-validate form-horizontal">
                    <!-- START panel-->
                    <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading }">
                        <div class="panel-body">
                            <fieldset class="b0">
                                <legend>大楼信息</legend>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">大楼号</label>
                                    <div class="col-sm-4">
                                        <input maxlength="128" type="text" name="NickName" required="" ng-model="model.NickName" class="form-control" disabled="disabled" />
                                    </div>
                                    <div class="col-sm-4">
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">楼层数</label>
                                    <div class="col-sm-4">
                                        <input maxlength="50" type="text" name="Balance" required="" ng-model="model.Balance" class="form-control" disabled="disabled" />
                                    </div>
                                    <div class="col-sm-4">
                                        @*<h4 class="text-danger">*</h4>*@
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">单元数</label>
                                    <div class="col-sm-4">
                                        <input maxlength="50" type="text" name="Points" required="" ng-model="model.Points" class="form-control" disabled="disabled" />
                                    </div>
                                    <div class="col-sm-4">
                                        @*<h4 class="text-danger">*</h4>*@
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">房间数</label>
                                    <div class="col-sm-4">
                                        <input maxlength="128" type="text" name="NickName" required="" ng-model="model.NickName" class="form-control" disabled="disabled" />
                                    </div>
                                    <div class="col-sm-4">
                                        @*<h4 class="text-danger">*</h4>*@
                                    </div>
                                </div>
                            </fieldset>
                            
                            <div ng-if="interacted(dataForm.sex)" ng-messages="dataForm.sex.$error" ng-messages-include="form-messages"></div>
                        </div>
                        <div class="panel-footer text-right">
                            <button type="button" class="btn btn-warning" ng-click="cancel()">返回列表</button>
                            <button type="button" class="btn btn-primary" ng-click="save()">保存</button>
                        </div>
                    </div>
                    <!-- END panel-->
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    App.controller('MemberDetailController', ["$scope", "$state", "$http", "$stateParams", "Notify", "$filter",
        function ($scope, $state, $http, $stateParams, Notify, $filter) {
            'use strict';
            $scope.submitted = false;
            $scope.isLoading = true;
            $scope.validateInput = function (name, type) {
                var input = $scope.formValidate[name];
                return (input.$dirty || $scope.submitted) && input.$error[type];
            };

            //$scope.changeP = function (provinceName) {
            //    $rootScope.getCities(provinceName);
            //    $scope.AgentInfo.HomeCity = '';
            //}

            //$scope.changeC = function (cityName) {
            //    $rootScope.getAreas(cityName);
            //}

            //数据初始化
            $http.post("/Member/GetMemberInfo", { Id: $stateParams.id }).then(function (response) {
                console.log(response);
                $scope.model = response.data;
                if (!$scope.model) {
                    Notify.alert("该会员不存在", { status: 'warning' });
                    $state.go('app.memberlist');
                    $scope.model = {};
                }
                //$rootScope.initArea($scope.AgentInfo.HomeProvince, $scope.AgentInfo.HomeCity);
                $scope.isLoading = false;
            });
            // 提交
            $scope.save = function () {
                debugger
                $scope.submitted = true;
                $scope.isLoading = true;
                //if ($scope.formValidate.$valid) {
                $http.post("/Member/SaveMember", { model: $scope.model }).then(function (returnData) {
                    if (returnData.data.isSuccess) {
                        Notify.alert('保存成功!', { status: 'success' });
                        $state.go("app.memberlist");
                    } else {
                        Notify.alert(returnData.data.msg, { status: 'warning' });
                        $scope.isLoading = false;
                    }
                });
                //} else {
                //    $scope.isLoading = false;
                //}
            };

            //返回列表
            $scope.cancel = function () {
                $state.go('app.memberlist');
            }
        }]);
</script>
